import request from "./request";

const Login = (data) => {
    return request({
        method: "post",
        url: "/user/login",
        data
    });
};

const Logout = () => {
    return request({
        url: "/user/logout"
    });
};

const GetUser = (id) => {
    return request({
        url: `/user/${id}`
    });
};

const GetUsers = () => {
    return request({
        url: "/user/list"
    });
};

const DeleteUser = (id) => {
    return request({
        url: `/user/${id}`,
        method: "delete"
    });
};

const AddUser = (username, password, repeatpwd, avatar) => {
    return request({
        url: "/user/register",
        method: "post",
        data: { username, password, repeatpwd, avatar }
    });
};

const UploadPic = (data) => {
    return request({
        url: "/common/upload",
        method: "post",
        data: data,
        headers: { "Content-Type": "multipart/form-data" }
    });
};

export { Login, GetUser, Logout, GetUsers, DeleteUser, AddUser, UploadPic };
